import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { TagForm, TagQuery, TagVO } from '@/api/exam/tag/types';

const apiPrefix = '/exam/tag/';
/**
 * 查询标签分页列表
 * @param query
 * @returns {*}
 */

export const pageTag = (query?: TagQuery): AxiosPromise<TagVO[]> => {
  return request({
    url: apiPrefix + 'page',
    method: 'get',
    params: query
  });
};

/**
 * 查询标签列表
 * @param query
 * @returns {*}
 */
export function listTag(query?: TagQuery): AxiosPromise<TagVO[]> {
  return request({
    url: apiPrefix + 'list',
    method: 'get',
    params: query
  });
}

/**
 * 查询标签类型详细
 * @param tagId
 */
export const getTagType = (tagId: string | number): AxiosPromise<TagVO> => {
  return request({
    url: apiPrefix + tagId,
    method: 'get'
  });
};

/**
 * 新增标签类型
 * @param data
 */
export const addTagType = (data: TagForm) => {
  return request({
    url: apiPrefix,
    method: 'post',
    data: data
  });
};

/**
 * 修改标签类型
 * @param data
 */
export const updateTagType = (data: TagForm) => {
  return request({
    url: apiPrefix,
    method: 'put',
    data: data
  });
};

/**
 * 删除标签类型
 * @param tagId
 */
export const delTagType = (tagId: string | number | Array<string | number>) => {
  return request({
    url: apiPrefix + tagId,
    method: 'delete'
  });
};


